import http from "./requst"; // 引入你的axios实例
export function uploadFile(file, url, bodyName) {
  let url_ = url || "/common/Upload/UpFile";
  return new Promise(async (resolve, reject) => {
    const formData = new FormData();
    formData.append("file", file); // 'file' 是后端期望的字段名
    try {
      const response = await http.post(url_, formData, {
        headers: {
          "Content-Type": "multipart/form-data", // 设置Content-Type为multipart/form-data
        },
      });
      resolve(response);
      // 处理上传成功的逻辑，如显示消息、更新状态等
    } catch (error) {
      reject();
      // 处理上传失败的逻辑，如显示错误消息、更新状态等
    }
  });
}
